﻿namespace Neovolve.Extensibility.ReSharper
{
    using System;

    /// <summary>
    /// The <see cref="ConvertTypeHighlighting"/>
    ///   class is used to define the highlighting for a type conversion.
    /// </summary>
    [CLSCompliant(false)]
    public class ConvertTypeHighlighting : HighlightingBase
    {
        /// <summary>
        /// Stores the bulb item related to the highlighting.
        /// </summary>
        private readonly IConvertTypeBulbItem _bulbItem;

        /// <summary>
        /// Initializes a new instance of the <see cref="ConvertTypeHighlighting"/> class.
        /// </summary>
        /// <param name="highlightingName">
        /// Name of the highlighting.
        /// </param>
        /// <param name="bulbItem">
        /// The bulb item.
        /// </param>
        public ConvertTypeHighlighting(String highlightingName, IConvertTypeBulbItem bulbItem)
            : base(highlightingName, bulbItem.Descriptor.Node, bulbItem.Text)
        {
            _bulbItem = bulbItem;
        }

        /// <summary>
        /// Determines whether this instance is valid.
        /// </summary>
        /// <returns>
        /// <c>true</c> if this instance is valid; otherwise, <c>false</c>.
        /// </returns>
        public override Boolean IsValid()
        {
            if (BulbItem.Descriptor.IsValid == false)
            {
                return false;
            }

            return base.IsValid();
        }

        /// <summary>
        /// Gets the bulb item related to the highlighting.
        /// </summary>
        /// <value>
        /// The bulb item.
        /// </value>
        public IConvertTypeBulbItem BulbItem
        {
            get
            {
                return _bulbItem;
            }
        }
    }
}